package org.argeproje.resim.ui.component.histogram;
import org.argeproje.resim.proc.histogram.LocalHistogramEqualizePR;
import org.argeproje.resim.proc.histogram.StatisticalHistogramPR;
import org.argeproje.resim.property.FloatPRP;
import org.argeproje.resim.property.IntegerPRP;
import org.argeproje.resim.ui.model.ComponentItem;
public class StatisticalHistogramCI extends ComponentItem {
	private static final long serialVersionUID = 1;
	private static final String LOCAL_WIDTH_PROP = "StatisticalHistogramCI._localWidth";	
	private int _localWidth;
	private static final String LOCAL_HEIGHT_PROP = "StatisticalHistogramCI._localHeight";	
	private int _localHeight;
	private static final String INTENSITY_MULTIPLIER_PROP = "StatisticalHistogramCI._intensityMultiplier";	
	private int _intensityMultiplier;
	private static final String MEAN_UPPER_LIMIT_PROP = "StatisticalHistogramCI._meanUpperLimit";	
	private float _meanUpperLimit;
	private static final String VARIANCE_LOWER_LIMIT_PROP = "StatisticalHistogramCI._varianceLowerLimit";	
	private float _varianceLowerLimit;
	private static final String VARIANCE_UPPER_LIMIT_PROP = "StatisticalHistogramCI._varianceUpperLimit";	
	private float _varianceUpperLimit;
	public StatisticalHistogramCI()
	{		
		super();
		_name = "Statistical\nHistogram\nEqualize";
		_description = "";
		initProc();
	}
	public void setLocalWidth(int value)
	{
		_localWidth = value;
	}
	public int getLocalWidth()
	{
		return _localWidth;
	}	
	public void setLocalHeight(int value)
	{
		_localHeight = value;
	}
	public int getLocalHeight()
	{
		return _localHeight;
	}
	public int getIntensityMultiplier() {
		return _intensityMultiplier;
	}
	public void setIntensityMultiplier(int multiplier) {
		_intensityMultiplier = multiplier;
	}
	public float getMeanUpperLimit() {
		return _meanUpperLimit;
	}
	public void setMeanUpperLimit(float upperLimit) {
		_meanUpperLimit = upperLimit;
	}
	public float getVarianceLowerLimit() {
		return _varianceLowerLimit;
	}
	public void setVarianceLowerLimit(float lowerLimit) {
		_varianceLowerLimit = lowerLimit;
	}
	public float getVarianceUpperLimit() {
		return _varianceUpperLimit;
	}
	public void setVarianceUpperLimit(float upperLimit) {
		_varianceUpperLimit = upperLimit;
	}
	protected void initDescriptorList()
	{
		super.initDescriptorList();
		registerProperty(new IntegerPRP(this,
				LOCAL_WIDTH_PROP, "Local Width", "getLocalWidth", "setLocalWidth"));
		registerProperty(new IntegerPRP(this,
				LOCAL_HEIGHT_PROP, "Local Height", "getLocalHeight", "setLocalHeight"));
		registerProperty(new IntegerPRP(this,
				INTENSITY_MULTIPLIER_PROP, "Intensity Multiplier", "getIntensityMultiplier", "setIntensityMultiplier"));
		registerProperty(new FloatPRP(this,
				MEAN_UPPER_LIMIT_PROP, "Mean Upper Limit", "getMeanUpperLimit", "setMeanUpperLimit"));
		registerProperty(new FloatPRP(this,
				VARIANCE_LOWER_LIMIT_PROP, "Variance Lower Limit", "getVarianceLowerLimit", "setVarianceLowerLimit"));
		registerProperty(new FloatPRP(this,
				VARIANCE_UPPER_LIMIT_PROP, "Variance Upper Limit", "getVarianceUpperLimit", "setVarianceUpperLimit"));
	}

	@Override
	public Class<StatisticalHistogramCI> getComponentClass() {
		// TODO Auto-generated method stub
		return StatisticalHistogramCI.class;
	}

	public void initProc() {
		if(_processor == null)
		{
			_processor = new StatisticalHistogramPR();			
		}
		_localWidth = ((StatisticalHistogramPR)_processor).getParamLocalWidth();
		_localHeight = ((StatisticalHistogramPR)_processor).getParamLocalHeight();
		_intensityMultiplier = ((StatisticalHistogramPR)_processor).getParamIntensityMultiplier();
		_meanUpperLimit = ((StatisticalHistogramPR)_processor).getParamMeanUpperLimit();
		_varianceLowerLimit = ((StatisticalHistogramPR)_processor).getParamVarianceLowerLimit();
		_varianceUpperLimit = ((StatisticalHistogramPR)_processor).getParamVarianceUpperLimit();
	}
	
	public void updateProc() {
		if(_processor == null)
		{
			_processor = new StatisticalHistogramPR();			
		}
		((StatisticalHistogramPR)_processor).setParameters(_localWidth, _localHeight, _intensityMultiplier,
				_meanUpperLimit, _varianceLowerLimit, _varianceUpperLimit);
	}
}
